<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- For use in test domain -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>xssinterface Unit-Test</title>

<script type="text/javascript" src="test_simple.js"></script>
<script type="text/javascript" src="test.js"></script>

<script type="text/javascript" src="/xssinterface/js/json2.js"></script>
<script type="text/javascript" src="/xssinterface/js/xssinterface.js"></script>



<script type="text/javascript">

window.query = new XSSInterface.Query();

XSSInterfaceEnablePostMessageSupport = query.param('enablePostMessage') == "1" ? true : false;
XSSInterfaceEnableGoogleGearsSupport = query.param('enableGoogleGears') == "1" ? true : false;

MyDomain    = document.location.hostname
// Very bad security hole. DO NOT USE SOMETHING LIKE THIS IN PRODUCTION CODE
OtherDomain = query.param("otherDomain")


function sayHello(which) {

	var message = $('input').value;
	var color   = $('color').options[$('color').selectedIndex].value;

	window["xssCaller"+which].call("hello", message, color)
}

function $(id) {
	return document.getElementById(id)
}

function iframeHTML(index) {
	var html = '<iframe src="http://'+OtherDomain+'/xssinterface/examples/test/iframe'+index+'.html?enablePostMessage='+window.query.param('enablePostMessage')+'&enableGoogleGears='+window.query.param('enableGoogleGears')+'&allowDomain='+MyDomain+'" width="500" height=200 id="iframe'+index+'" name="iframe'+index+'"></iframe>';
    return html   
}


</script>

</head>

<body onload="bind(); ">
<h1>xssinterface automated tests</h1>

<p>
  <input type=button   id=runButton value="Run Test" onclick="runTest()">
</p>

<div id="testLog" style="">
</div>

<form>

<table border="1">
  <tr>
    <td width="97">My Domain</td>
    <td width="287">
      <b><script type="text/javascript">
      document.write(document.location.hostname)
	  </script></b>
    </td>
  </tr>
  <tr>
    <td>IFrame 1</td>
    <td>
      <script type="text/javascript">
        document.write(iframeHTML(1))
      </script>
    </td>
  </tr>
  <tr>
    <td>IFrame 2</td>
    <td>
      <script type="text/javascript">
        document.write(iframeHTML(2))
      </script>  
    </td>
  </tr>
</table>

<div id="setter"></div>
<div id="log"></div>

</form>

</body>
</html>